home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 025a / prgmchk.zip / QUOTECHK.CMD < prev    next >
OS/2 REXX Batch file  |  1991-07-21  |  4KB  |  117 lines

  1. *(QUOTECHK.CMD - Quote checker routine -
  2.      This routine totals the number of quotation marks per line and prints
  3.      the line if the counts are odd:  If the counts are odd but the line
  4.      ends with a + (the Rbase continuation symbol) then the routine skips
  5.      to the next line before comparing totals. The routine also skips full
  6.      comment lines,ie-lines beginning with -- or beginning with a *( and
  7.      ending with ).  It also skips any line starting with SET QUO, ie-the
  8.      set quotes command.
  9.                                              created 19 July 91; Wm Driskell)
  10. set mess off
  11. set err mess off
  12. set err var verr
  13. set v blnk text = (char(32))
  14. set v lastchar text = .blnk
  15. set v oddchar = (char(254))
  16. set quote = .oddchar        *(oddchar=■)
  17. set zero on
  18. set v lineknt int = 0
  19. CLS
  20. WRITE ■Quotation Marks Checker■
  21. WRITE ■-----------------------■
  22. WRITE ■ ■
  23.  
  24. fillin ifile$ using ■Enter name of file to check: ■
  25. fillin ofile$ using ■Enter name of file for output: ■
  26. out .ofile$
  27. write ■File: ■,.ifile$
  28. write ■ ■
  29. out scr
  30.  
  31. *( setup counters and constants )
  32.  set var fqknt int = 0, sqknt int = 0
  33.  set var fq$ = (CHAR(34))  *(double or full quote)
  34.  set var sq$ = (CHAR(39))  *(single quote)
  35.  set var ap = (char(254) + char(42) + char(40) +char(254))  *(comment chars)
  36.  set var lp = (char(254) + char(41) +char(254))
  37.  set var dd = (char(254) + char(45) + char(45) + char(254))
  38.  set var plus = (char(254) + char(43) + char(254))
  39.  
  40. *( load file into table as lines of text by temporarily changing the blank
  41.    character to fool the RBase ASCII-input-parsing routine )
  42. drop cursor c1
  43. drop tab t$$
  44. write ■loading the data...■
  45. create tab T$$ codeline text 100
  46. set blank =.oddchar
  47. load■t$$■from■.ifile$■as■ascii
  48. set■blank=.blnk
  49.  
  50. WRITE ■ ■
  51. WRITE ■Line #: total quote count, " and '■
  52. write ■----------------------------------■
  53. compute lk as rows from T$$
  54. *( get line and parse for parentheses )
  55.  declare c1 cursor for select codeline from t$$
  56.  open c1
  57.  fetch c1 into a$ ind1
  58. while sqlcode <> 100 then
  59.   set v lineknt = .lineknt + 1
  60.   write ■line■,.lineknt,■of■,.lk at 1 65 reverse
  61.   set v vslen = (slen(.a$))
  62.  if a$ not cont .fq$ and a$ not cont .sq$ then
  63.   GOTO skipline
  64.  endif
  65.  set v remchk = (sget(a$,2,1))
  66.  IF (lastchar <> .plus) AND ((remchk = .dd) OR +
  67.     (remchk = .ap AND sget(.a$,1,.vslen) = .lp)) THEN
  68.     GOTO skipline   *( skip a full comment line )
  69.  ENDIF
  70.   set v vsloc = (sloc(.a$,■set qu■))
  71.   IF vsloc > 0 THEN
  72.    GOTO skipline    *( skip a SET QUOTE statement )
  73.   ENDIF
  74.     set v l = (sloc(.a$, fq$))
  75.     set v r = (sloc(.a$, sq$))
  76.     set v b$ = .a$
  77.   while (.l + .r) > 0 then
  78.     IF l > 0 THEN
  79.      set v b$ = (sput(b$,■!■,.l))
  80.      set v fqknt = .fqknt + 1
  81.     ENDIF
  82.     IF r > 0 THEN
  83.      set v b$ = (sput(b$,■!■,.r))
  84.      set v sqknt = .sqknt + 1
  85.     ENDIF
  86.     set v l = (sloc(.b$, fq$))
  87.     set v r = (sloc(.b$, sq$))
  88.   endwhile
  89. label skipline
  90.  set v lastchar = (sget(a$,1,.vslen))      *(check for continuation char)
  91.  IF (MOD(.fqknt,2) = 1 OR MOD(.sqknt,2) = 1) AND .lastchar <> ■+■ THEN
  92.  out scr with .ofile$ append
  93.   WRITE ■==>■,.lineknt,■: ■, .fqknt, .sqknt
  94.   WRITE .a$
  95.  out scr
  96.  ENDIF
  97. fetch c1 into a$ ind1
  98. endwhile
  99. drop cursor c1
  100. out scr with .ofile$ append
  101.  WRITE ■ ■
  102.  WRITE ■::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::■
  103.  WRITE ■ ■
  104.  WRITE ■total lines processed: ■,.lineknt
  105.  WRITE ■total number of quotes processed: ■
  106.  WRITE ■                " - ■,.fqknt
  107.  WRITE ■                ' - ■,.sqknt
  108.  WRITE ■       (ignoring full comment lines and SET QUOTE commands)■
  109.  WRITE ■::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::■
  110.  WRITE ■ ■
  111. out scr
  112. set quote='
  113. drop tab t$$
  114. clear var blnk,plus,lastchar,oddchar,lineknt,a$,b$,fqknt,sqknt,fq$,sq$,l,r+
  115. vsloc,vslen,remchk,ofile$,ifile$,ind1,ap,lp,dd
  116. return
  117.